package cn.com.utt.unms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.utt.unms.mapper.AddressMapper;
import cn.com.utt.unms.mapper.GroupNetworkMapper;
import cn.com.utt.unms.pojo.City;
import cn.com.utt.unms.pojo.District;
import cn.com.utt.unms.pojo.Province;
import cn.com.utt.unms.service.AddressService;

@Service("addressService")
public class AddressServiceImpl implements AddressService {

	@Autowired
	private AddressMapper addressMapper;
	
	@Autowired
	private GroupNetworkMapper groupNetworkMapper;

	@Override
	public List<Province> queryAllProvinces() {
		return addressMapper.queryAllProvinces();
	}

	@Override
	public List<District> getDistrictByCityId(long id) {
		return addressMapper.getDistrictByCityId(id);
	}

	@Override
	public List<City> getCityByProvinceId(long id) {
		return addressMapper.getCityByProvinceId(id);
	}

	@Override
	public List<Map<String, Object>> map(long groupId) {
		List<Long> networkIds = groupNetworkMapper.queryByGroupId(groupId);
		if(networkIds != null && !networkIds.isEmpty()){
			return addressMapper.getMapByNetwork(networkIds);
		}
		return null;
	}

}